import request from '@/utils/request'

export function listGoods(query) {
  return request({
    url: '/goods/list',
    method: 'get',
    params: query
  })
}

export function deleteGoods(data) {
  return request({
    url: '/goods/delete',
    method: 'post',
    data
  })
}

export function publishGoods(data) {
  return request({
    url: '/goods/create',
    method: 'post',
    data
  })
}

export function detailGoods(id) {
  return request({
    url: '/goods/detail',
    method: 'get',
    params: { id }
  })
}

export function editGoods(data) {
  return request({
    url: '/goods/update',
    method: 'post',
    data
  })
}

export function listCatAndBrand() {
  return request({
    url: '/goods/catAndBrand',
    method: 'get'
  })
}
// 配方all
export function allFormula() {
  return request({
    url: '/goods/formula/all',
    method: 'get'
  })
}
// 配方列表
export function listFormula(query) {
  return request({
    url: '/goods/formula/list',
    method: 'get',
    params: query
  })
}
// 配方详情
export function detailFormula(row) {
  return request({
    url: `/goods/formula/detail/${row.id}`,
    method: 'get'
  })
}
// 配方新增
export function insertFormula(data) {
  return request({
    url: '/goods/formula/insert',
    method: 'post',
    data
  })
}
//  配方更新
export function editFormula(data) {
  return request({
    url: '/goods/formula/update',
    method: 'post',
    data
  })
}
// 删除配方
export function deleteFormula(row) {
  return request({
    url: `/goods/formula/delete/${row.id}`,
    method: 'delete'
  })
}
// 配方新增属性
export function insertFormulaAttr(data) {
  return request({
    url: '/goods/formula/attr/insert',
    method: 'post',
    data
  })
}
// 配方编辑属性
export function updateFormulaAttr(data) {
  return request({
    url: '/goods/formula/attr/update',
    method: 'post',
    data
  })
}
// 删除配方属性
export function deleteFormulaAttr(row) {
  return request({
    url: `/goods/formula/attr/delete/${row.id}`,
    method: 'delete'
  })
}
// 原料管理列表
export function listMaterial(query) {
  return request({
    url: '/goods/material/list',
    method: 'get',
    params: query
  })
}
// 原料管理
export function allMaterial(query) {
  return request({
    url: '/goods/material/all',
    method: 'get',
    params: query
  })
}
// 原料新增
export function insertMaterial(data) {
  return request({
    url: '/goods/material/insert',
    method: 'post',
    data
  })
}
// 原料更新
export function editMaterial(data) {
  return request({
    url: '/goods/material/update',
    method: 'post',
    data
  })
}
// 删除原料
export function deleteMaterial(row) {
  return request({
    url: `/goods/material/delete/${row.id}`,
    method: 'get'
  })
}
